﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using OgilvyOne.BLL;
using OgilvyOne.Model;

public partial class admin_infomation_brand_select : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            string brands = Request.Params["brands"];
            ListBox1.Items.Clear();
            BrandInfoBll catb = new BrandInfoBll();
            DataSet ls = catb.GetAllList();
            this.ListBox1.DataSource = ls;
            this.ListBox1.DataTextField = "BRAND_NAME";
            this.ListBox1.DataValueField = "BRAND_ID";
            this.ListBox1.DataBind();
            this.Button5.Attributes.Add("onclick", "window.close()");
            if (brands != null && brands.Trim() != "")
            {
                string[] tags = brands.Split(',');
                for (int i = 0; i < tags.Length; i++)
                {
                    for (int j = 0; j < ListBox1.Items.Count; j++)
                    {
                        string us = tags[i].ToString();
                        if (ListBox1.Items[j].Value.ToString() == us)
                        {
                            ListItem lit = new ListItem(ListBox1.Items[j].Text.ToString(), ListBox1.Items[j].Value.ToString());
                            ListBox2.Items.Add(lit);
                            ListBox1.Items.Remove(ListBox1.Items[j]);
                            ListBox2.SelectedIndex = -1;
                        }
                    }
                }
            }
            else
            {

            }
        }
    }
    //搜索按钮
    protected void Search_Click(object sender, EventArgs e)
    {
        ListBox1.Items.Clear();
        BrandInfoBll catb = new BrandInfoBll();
        CmsArticleTagModel catm = new CmsArticleTagModel();
        if (brandname.Text != null && brandname.Text.ToString().Trim() != "")
        {
            catm.TagName = this.brandname.Text.ToString().Trim();
        }
        DataSet ls = catb.GetList(" BRAND_NAME like '%" + brandname.Text + "%'");
        this.ListBox1.DataSource = ls;
        this.ListBox1.DataTextField = "BRAND_NAME";
        this.ListBox1.DataValueField = "BRAND_ID";
        this.ListBox1.DataBind();
    }
    //选择
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (ListBox1.SelectedIndex != -1)
        {
            ListBox2.Items.Add(ListBox1.SelectedItem);
            ListBox1.Items.Remove(ListBox1.SelectedItem);
            ListBox2.SelectedIndex = -1;
        }
        else
        {
            ListBox1.SelectedIndex = 0;
        }
    }
    //删除
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (ListBox2.SelectedIndex != -1)
        {
            ListBox1.Items.Add(ListBox2.SelectedItem);
            ListBox2.Items.Remove(ListBox2.SelectedItem);
            ListBox1.SelectedIndex = -1;
        }
        else
        {
            ListBox2.SelectedIndex = 0;
        }
    }
    //确定
    protected void Button4_Click(object sender, EventArgs e)
    {
        
    }
}
